﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using caedisi.Web.DataModel;
using System.ComponentModel;

namespace caedisi.Views
{
    /// <summary>
    /// The edit window of the NeighbourhoodDefinition
    /// </summary>
    public partial class NeighbourhoodDefinitionEdit : ChildWindow, INotifyPropertyChanged
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="NeighbourhoodDefinitionEdit"/> class.
        /// </summary>
        public NeighbourhoodDefinitionEdit()
        {
            InitializeComponent();
        }

        private NeighbourhoodType _CurrentEntity;
        /// <summary>
        /// Gets or sets the current cellular automata.
        /// </summary>
        /// <value>
        /// The current cellular automata.
        /// </value>
        public NeighbourhoodType CurrentEntity
        {
            get
            {
                return _CurrentEntity;
            }
            set
            {
                if (_CurrentEntity != value)
                {
                    _CurrentEntity = value;
                    this.RaisePropertyChanged("CurrentEntity");

                }
            }
        }


        /// <summary>
        /// Initializes a new instance of the <see cref="NeighbourhoodDefinitionEdit"/> class.
        /// </summary>
        /// <param name="currentNeighbourhoodType">Type of the current neighbourhood.</param>
        public NeighbourhoodDefinitionEdit(NeighbourhoodType currentNeighbourhoodType)
        {
            InitializeComponent();
            this.DataContext = this;
            this.CurrentEntity = currentNeighbourhoodType;
        }

        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = true;
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }


        public event PropertyChangedEventHandler PropertyChanged;
        /// <summary>
        /// Raises the property changed.
        /// </summary>
        /// <param name="propertyName">Name of the property.</param>
        protected virtual void RaisePropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = this.PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }

      
    }
}

